﻿@{
    ViewBag.Title = "模块管理》表单页面";
    Layout = "~/Views/Shared/_LayoutForm.cshtml";
}
<script type="text/javascript">
    $(function () {
        BindCombobox();
        InitControl();
    })
    //初始化绑定下拉框
    function BindCombobox() {
        //公司分类
        BindDropItem("#Category", "CompanyCategory", "==请选择=");
        //公司性质
        BindDropItem("#Nature", "CompanyNature", "==请选择=");
        //所在省
        $("#ProvinceId").append("<option value=''>==请选择==</option>");
        $("#CityId").append("<option value=''>==请选择==</option>");
        $("#CountyId").append("<option value=''>==请选择==</option>");
        AjaxJson("/Utility/GetProvinceCityListJson", { ParentId: 0 }, function (DataJson) {
            $.each(DataJson, function (i) {
                $("#ProvinceId").append($("<option></option>").val(DataJson[i].Code).html(DataJson[i].FullName));
            });
        })
        //所在市
        $("#ProvinceId").change(function () {
            BindCityId();
        });
        //所在县区
        $("#CityId").change(function () {
            BindCountyId();
        });
    }
    //所在市下拉框
    function BindCityId() {
        $("#CityId").html("");
        $("#CityId").append("<option value=''>==请选择==</option>");
        AjaxJson("/Utility/GetProvinceCityListJson", { ParentId: $("#ProvinceId").val() }, function (DataJson) {
            $.each(DataJson, function (i) {
                $("#CityId").append($("<option></option>").val(DataJson[i].Code).html(DataJson[i].FullName));
            });
        })
    }
    //所在县区
    function BindCountyId() {
        $("#CountyId").html("");
        $("#CountyId").append("<option value=''>==请选择==</option>");
        AjaxJson("/Utility/GetProvinceCityListJson", { ParentId: $("#CityId").val() }, function (DataJson) {
            $.each(DataJson, function (i) {
                $("#CountyId").append($("<option></option>").val(DataJson[i].Code).html(DataJson[i].FullName));
            });
        })
    }
    //得到一个对象实体
    function InitControl() {
        if (!!GetQuery('KeyValue')) {
            AjaxJson("/CommonModule/Company/SetCompanyForm", { KeyValue: GetQuery('KeyValue') }, function (data) {
                SetWebControls(data);
                BindCityId();
                $("#CityId").val(data.CityId);
                BindCountyId();
                $("#CountyId").val(data.CountyId);
            });
        } else {
            //显示顺序
            AjaxJson("/CommonModule/Company/SortCode", {}, function (Data) {
                $("#SortCode").val(Data);
            })
            if (!!GetQuery('CompanyId')) {
                $("#ParentId").val(GetQuery('CompanyId'));
            } else {
                $("#ParentId").val(0);
            }
        }
    }
    //保存事件
    function AcceptClick() {
        if (!CheckDataValid('#form1')) {
            return false;
        }
        Loading(true, "正在提交数据...");
        window.setTimeout(function () {
            var postData = GetWebControls("#form1");
            postData["BuildFormJson"] = JSON.stringify(GetWebControls("#CustomAttribute"));
            AjaxJson("/CommonModule/Company/SubmitCompanyForm?KeyValue=" + GetQuery('KeyValue'), postData, function (data) {
                tipDialog(data.Message, 3, data.Code);
                top.frames[tabiframeId()].windowload();
                closeDialog();
            });
        }, 200);
    }
</script>
<form id="form1">
    <div id="message" style="display: none; padding: 1px; padding-bottom: 0px;"></div>
    <div class="bd" style="border-bottom: none; margin: 1px;">
        <div class="tipstitle_title settingtable bold bd todayInfoPanelTab rightPanelTitle_normal">
            <div class="tab_list_top" style="position: absolute">
                <div id="Tabbasic" class="tab_list bd actived" onclick="Tabchange('basic')">基本信息</div>
                <div id="TabCustomAttribute" class="tab_list bd " onclick="Tabchange('CustomAttribute')">自定义属性</div>
            </div>
        </div>
    </div>
    <div class="ScrollBar" style="margin: 1px;overflow:hidden;">
        <!--基本信息-->
        <div id="basic" class="tabPanel">
            <table class="form">
                <tr>
                    <th class="formTitle">公司编码：
                    </th>
                    <td class="formValue">
                        <input id="ParentId" type="hidden" />
                        <input id="Code" type="text" class="txt required" datacol="yes" err="公司编码" checkexpession="NotNull" />
                    </td>
                    <th class="formTitle">公司名称：
                    </th>
                    <td class="formValue">
                        <input id="FullName" type="text" class="txt required" datacol="yes" err="公司名称" checkexpession="NotNull" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">公司简称：
                    </th>
                    <td class="formValue">
                        <input id="ShortName" type="text" class="txt" />
                    </td>
                    <th class="formTitle">公司分类：
                    </th>
                    <td class="formValue">
                        <select id="Category" class="txtselect required" datacol="yes" err="公司分类" checkexpession="NotNull"></select>
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">公司性质：
                    </th>
                    <td class="formValue">
                        <select id="Nature" class="txtselect" datacol="yes" err="公司性质" checkexpession="NotNull"></select>
                    </td>
                    <th class="formTitle">公司法人：</th>
                    <td class="formValue">
                        <input id="Manager" type="text" class="txt" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">联系人：</th>
                    <td class="formValue">
                        <input id="Contact" type="text" class="txt" />
                    </td>
                    <th class="formTitle">联系电话：</th>
                    <td class="formValue">
                        <input id="Phone" type="text" class="txt" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">电子邮件：</th>
                    <td class="formValue">
                        <input id="Email" type="text" class="txt" />
                    </td>
                    <th class="formTitle">传真：</th>
                    <td class="formValue">
                        <input id="Fax" type="text" class="txt" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">所在省：</th>
                    <td class="formValue">
                        <select id="ProvinceId" class="txtselect"></select>
                    </td>
                    <th class="formTitle">所在市：</th>
                    <td class="formValue">
                        <select id="CityId" class="txtselect"></select>
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">所在县区：</th>
                    <td class="formValue">
                        <select id="CountyId" class="txtselect"></select>
                    </td>
                    <th class="formTitle">邮编编码：</th>
                    <td class="formValue">
                        <input id="Postalcode" type="text" class="txt" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">详细地址：</th>
                    <td class="formValue" colspan="3">
                        <input id="Address" type="text" class="txt" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">公司网址：</th>
                    <td class="formValue">
                        <input id="Web" type="text" class="txt" />
                    </td>
                    <th class="formTitle">开户信息：</th>
                    <td class="formValue">
                        <input id="AccountInfo" type="text" class="txt" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">显示顺序：</th>
                    <td class="formValue">
                        <input id="SortCode" type="text" onkeyup="IsNumber(this.id)" class="txt required" datacol="yes" err="显示顺序" checkexpession="Num" />
                    </td>
                    <th class="formTitle">选项：</th>
                    <td class="formValue">
                        <span class="item">
                            <input type="checkbox" name="checkbox" checked="checked" id="Enabled" />
                            <label for="Enabled">有效</label>
                        </span>
                    </td>
                </tr>
                <tr>
                    <th class="formTitle">公司描述：
                    </th>
                    <td class="formValue" colspan="3">
                        <textarea id="Remark" name="Description" maxlength="200" class="txtArea" rows="3"></textarea>
                    </td>
                </tr>
            </table>
        </div>
        <!--自定义属性-->
        <div id="CustomAttribute" class="tabPanel" style="display: none;">
            @Html.Raw(@US.WebApp.BaseCommon.CreateBuildForm(2))
        </div>
    </div>
</form>
